package com.smh.a03exerciseDemo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test3 {
    public static void main(String[] args) {
        //一个流只能用一次

        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张三,21","李四,23","王五,25","李晓明,25","马天宇,28","小沈阳,27");

        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1,"杨幂,30","刘涛,28","关晓彤,27","白鹿,28","白百合,30","赵丽颖,32","杨颖,32");

        List<Actor> list3 = Stream.concat(list.stream()
                                .filter(s -> {
                                    return (s.split(",")[0].length()) == 3;
                                })
                                .limit(2),
                        list1.stream().filter(s -> {
                            String s1 = s.split(",")[0];
                            return s1.startsWith("杨");
                        }).skip(1))
                .map(s -> {
                    String[] split = s.split(",");
                    return new Actor(split[0], Integer.parseInt(split[1]));
                })
                .collect(Collectors.toList());

        System.out.println(list3);
        //可以分开写,但是每个流只能引用一次.
        //concat(nan,nv).map().collect();


    }
}
